package image;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
/**
 * This class is a variant of PCS which will fire events even though the old and new value is equal.
 */
@SuppressWarnings("serial")
public class PropertyEventSupport extends PropertyChangeSupport
	{
	Object source;
	public PropertyEventSupport(Object source)
		{
		super(source);
		this.source=source;
		}
	
	@Override
	/**
	 * Fire an event without killing it when oldValue==newValue
	 */
	public void firePropertyChange(String type,int oldValue,int newValue)
		{
		PropertyChangeListener[] listeners = this.getPropertyChangeListeners();
		PropertyChangeEvent event = new PropertyChangeEvent(this.source, type, oldValue, newValue);
		for(int i=0; i<listeners.length; i++)
			{
			listeners[i].propertyChange(event);
			}
		}

	}
